package com.xinsoft.controller.basic;


import com.fasterxml.jackson.core.JsonProcessingException;
import com.xinsoft.aop.ano.SysLog;
import com.xinsoft.common.ApplicationContextRegister;
import com.xinsoft.common.BusinessType;
import com.xinsoft.common.Response;
import com.xinsoft.jobs.BackUpsDBJob;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName BackUpDBController
 * @Description 数据备份
 * @Author lijie
 * @Date 2023年5月16日17:14:04
 * @Version 1.0
 */
@RestController
@RequestMapping("/system/db")
@Api(value = "BackUpDBController", tags = {"数据库备份控制层"})
public class BackUpDBController {


    /**
     * @Author Li9527
     * @Description 立即备份数据库
     * @Date 2023/5/17 19:50
     * @params
     * @return com.xinsoft.common.Response
     **/
    @PostMapping("/backUpDB")
    @ApiOperation(value = "立即备份")
    @SysLog(title = "数据库-立即备份", businessType = BusinessType.INSERT)
    public Response backUpDB() throws JsonProcessingException {
        Environment env = ApplicationContextRegister.getBean(Environment.class);
        BackUpsDBJob backUpsDBJob = new BackUpsDBJob();
        backUpsDBJob.backUpDB(env);
        return Response.succeed("备份成功");
    }


}

